package com.example.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
@RestController
public class CheckFileController {
    
    
    @GetMapping("/checkfile")
    public ResponseEntity<String> test(HttpServletResponse response, HttpServletRequest request) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
        headers.add("Content-Disposition", String.format("attachment; filename=%s", "aaa.html"));
        headers.add("Pragma", "no-cache");
        headers.add("Expires", "0");
        String a = "abcdefg";
        return ResponseEntity
                .ok()
                .headers(headers)
                .contentLength(a.getBytes().length)
                .contentType(MediaType.parseMediaType("application/octet-stream"))
                .body(a);
    }
    
    
}
